package cemp.controller;

import cemp.common.dto.Response;
import cemp.dto.DailyTaskDto;
import cemp.entity.DailyTask;
import cemp.service.DailyTaskService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/daily")
public class AppDailyTaskController {

    @Autowired
    DailyTaskService dailyTaskService;

    @GetMapping("/print")
    public String list() {
        System.out.println("print");
        return "print";
    }

    @GetMapping("/getall")
    public Response<List<DailyTaskDto>> getall() {
        return Response.success(dailyTaskService.getTasks());
    }

    @PostMapping("/update")
    public Response<Void> doUpdate(@RequestBody DailyTaskDto taskDto) {
        dailyTaskService.doupdate(taskDto);
        return Response.success();
    }

    @PostMapping("/add")
    public Response<Void> doAdd(@RequestBody DailyTaskDto taskDto) {
        dailyTaskService.doadd(taskDto);
        return Response.success();
    }

}
